package io.renren.modules.sys.service.impl;

import io.renren.common.utils.Constant;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.FyUsersDao;
import io.renren.modules.sys.entity.FyUsersEntity;
import io.renren.modules.sys.service.FyUsersService;


@Service("fyUsersService")
public class FyUsersServiceImpl extends ServiceImpl<FyUsersDao, FyUsersEntity> implements FyUsersService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String username = (String)params.get("username");

        IPage<FyUsersEntity> page = null;
        if(StringUtils.isNotBlank(username)){
            page = this.page(
                    new Query<FyUsersEntity>().getPage(params),
                    new QueryWrapper<FyUsersEntity>().like(StringUtils.isNotBlank(username),"user_name",username)
                            .apply(params.get(Constant.SQL_FILTER) != null, (String)params.get(Constant.SQL_FILTER))
            );
        }else{
            page = this.page(
                    new Query<FyUsersEntity>().getPage(params),
                    new QueryWrapper<FyUsersEntity>()
            );
        }


        return new PageUtils(page);
    }

}
